<?php 

class Item extends My_Controller
{
    public function index()
    {
        
    }
    function update_item()
    {
         if($this->session->userdata('role') == 1 || $this->session->userdata('role') == 3 ) {
        $data['rarity'] = $this->m_item->get_all_rarity();
        $data['hero'] = $this->m_item->get_all_hero();  
        $data['type'] = $this->m_item->get_all_type();
        $id = $this->uri->segment(3);   
        $item = $this->m_item->get_item_by_id($id);
       // var_dump($item); exit;
        $data['item']= $item;
        if($this->input->post('capnhat_item1') != '' )
        {
       /*     var_dump($this->input->post('is_hot')); echo "<br />";
            var_dump($this->input->post('is_sidebar')); echo "<br />";
            var_dump($this->input->post('is_slide')); echo "<br />"; exit;*/
            date_default_timezone_set('Asia/Ho_Chi_Minh');
            $date = getdate();
            $ngaycapnhat = $date['year'].'-'.$date['mon'].'-'.$date['mday'];
            $giamoi = $this->input->post('price');
            $hot = 0; $sidebar = 0; $slide = 0; $sale = 0;
            if($this->input->post('is_hot') == '1') $hot = 1;
            if($this->input->post('is_sidebar') == '1') $sidebar = 1;
            if($this->input->post('is_slide') == '1') $slide = 1;
             if($this->input->post('is_sale') == '1') $sale = 1;
       /*     var_dump( $this->input->post('hero_insert'));
            die();*/
            $kq = $this->m_item->update_item($id,$this->input->post('name'),$this->input->post('hero_insert'),$this->input->post('rarity_insert'),$this->input->post('type_insert'),
            $this->input->post('image'),$this->input->post('chitiet'),$hot,$sidebar,$slide,$sale);
            $add_gia = $this->m_item->update_price($id,$ngaycapnhat,$giamoi);
            redirect('item/update_item/'.$id);
        }
        
        $this->load->view('Item/Admin_edit_item',$data);
         } else redirect('account/login_admin');
    }
    public function get_info_item_by_id($id)
    {
    	$this->load->model('m_item');
    	$data['item_details'] = $this->m_item->get_Info_item_by_id($id);
        $data['hero'] = $this->m_item->get_all_hero();

        $set_name = $data['item_details'][0]->SET_ITEMS_NAME;
        if($set_name != '')
        {
            $data['related_items'] = $this->m_item->get_related_item($set_name, $id);
        }
        else
            $data['related_items'] = '';

        $data['item_previews'] = $this->m_item->get_preview_image_by_item_id($id);
    	$this->load->view('Item/Item_Details', $data);
    }
     
    
    public function add_new_item()
    {
          if($this->session->userdata('role') == 1 || $this->session->userdata('role') == 3 ) {
        date_default_timezone_set('Asia/Ho_Chi_Minh');
        $url = $this->input->post('url1');
        $date = getdate();
        $ngaycapnhat = $date['year'].'-'.$date['mon'].'-'.$date['mday'];
        $giamoi = $this->input->post('price');
        $add_item = $this->m_item->add_item($this->input->post('name'),$this->input->post('hero_insert'),$this->input->post('rarity_insert'),$this->input->post('type_insert'),$this->input->post('image'));
      //  echo mysqli_insert_id($this->db); exit;
        $id= $this->db->insert_id();
      //  var_dump($id);
        $add_gia = $this->m_item->update_price($id,$ngaycapnhat,$giamoi);
        redirect($url);
          } else redirect('account/login_admin');
    }
    
	 public function show_item_by_name($name)
    {
          if($this->session->userdata('role') == 1 || $this->session->userdata('role') == 3 ) {
        $this->load->library('pagination');
        $config['base_url']   = base_url(). "item/show_item_by_name/$name";
        $config['total_rows'] = $this->m_item->get_item_by_name_count($name);
        $config['per_page']   = 15;
        $config['use_page_numbers']=TRUE;
        $config['uri_segment'] = 4;
        
        $config['full_tag_open'] = '<ul class="pagination">';
        $config['full_tag_close'] = '</ul>';
        $config['prev_link'] = '&lt;';
        $config['prev_tag_open'] = '<li>';
        $config['prev_tag_close'] = '</li>';
        $config['next_link'] = '&gt;';
        $config['next_tag_open'] = '<li>';
        $config['next_tag_close'] = '</li>';
        $config['cur_tag_open'] = '<li class="active"><a href="#">';
        $config['cur_tag_close'] = '</a></li>';
        $config['num_tag_open'] = '<li>';
        $config['num_tag_close'] = '</li>';
         
        $config['first_tag_open'] = '<li>';
        $config['first_tag_close'] = '</li>';
        $config['last_tag_open'] = '<li>';
        $config['last_tag_close'] = '</li>';
         
        $config['first_link'] = '&lt;&lt;';
        $config['last_link'] = '&gt;&gt;';
        
        $this->pagination->initialize($config); 
        $tranghienhanh = $this->uri->segment(4)?$this->uri->segment(4):1;
        $start = ($tranghienhanh-1)*$config['per_page'];
        $data['pagination'] = $this->pagination->create_links();
        $data['rarity'] = $this->m_item->get_all_rarity();
        $data['hero'] = $this->m_item->get_all_hero();
        
      //  $data['hero_search'] = $he ;
      //  $data['rarity_search'] = $ra;
        
        $data['info'] = $this->m_item->get_item_by_name($name,$config['per_page'],$start);
      //  $data['views'] = 'Item/Admin_ajax_list_item';
            $this->load->view("Item/Admin_item_list_2",$data);
             } else redirect('account/login_admin');
    }
    public function show_item_2() //old
    {
           if($this->session->userdata('role') == 1 || $this->session->userdata('role') == 3 ) {
        if($this->input->post('text_search') != '')
                $he = $this->input->post('cboHero');
            else $he ='';
         $ra = $this->input->post('cboRarity');
         $ty = $this->input->post('cboType');
      //  var_dump($he); var_dump($ra);
        $this->load->library('pagination');
        $config['base_url']   = base_url(). "item/show_item_2";
        $config['total_rows'] = $this->m_item->count_data($he,$ra,$ty);
        $config['per_page']   = 15;
        $config['use_page_numbers']=TRUE;
        $config['uri_segment'] = 3;
         $config['full_tag_open'] = '<ul class="pagination">';
        $config['full_tag_close'] = '</ul>';
        $config['prev_link'] = '&lt;';
        $config['prev_tag_open'] = '<li>';
        $config['prev_tag_close'] = '</li>';
        $config['next_link'] = '&gt;';
        $config['next_tag_open'] = '<li>';
        $config['next_tag_close'] = '</li>';
        $config['cur_tag_open'] = '<li class="active"><a href="#">';
        $config['cur_tag_close'] = '</a></li>';
        $config['num_tag_open'] = '<li>';
        $config['num_tag_close'] = '</li>';
         
        $config['first_tag_open'] = '<li>';
        $config['first_tag_close'] = '</li>';
        $config['last_tag_open'] = '<li>';
        $config['last_tag_close'] = '</li>';
         
        $config['first_link'] = '&lt;&lt;';
        $config['last_link'] = '&gt;&gt;';
        $this->pagination->initialize($config); 
        $tranghienhanh = $this->uri->segment(3)?$this->uri->segment(3):1;
        $start = ($tranghienhanh-1)*$config['per_page'];
        $data['pagination'] = $this->pagination->create_links();
        $data['rarity'] = $this->m_item->get_all_rarity();
        $data['hero'] = $this->m_item->get_all_hero();  
        $data['type'] = $this->m_item->get_all_type();
        
        $data['info'] = $this->m_item->lay_danh_sach_san_pham_phan_trang($he,$ra,$ty,$config['per_page'],$start);
      //  $data['views'] = 'Item/Admin_ajax_list_item';
            $this->load->view("Item/Admin_item_list_2",$data);
          } else redirect('account/login_admin');
   //     $this->load->view('Item/Admin_item_list_2',$this->data);
    } 
    function show_item_search() //controller get input search ra
    {
         if($this->session->userdata('role') == 1 || $this->session->userdata('role') == 3 ) {
        $name = $this->input->post('item_name');
        if($name == '') {
            if($this->input->post('text_search') != '')
                $he = $this->input->post('cboHero');
            else $he ='';
      //  $he_temp = $this->input->post('text_search') ;
    //    echo $he; echo $he_temp; var_dump($he_temp); exit;
        $ra = $this->input->post('cboRarity');
        $ty = $this->input->post('cboType');
        if($he == '' ) $he = 'Allhero';
        if($ra == '' || $ra == 'All') $ra = 'All';
        if($ty == '' || $ty == 'All') $ty = 'All';
        $this->show_item_3($he,$ra,$ty); }
            else
            $this->show_item_by_name($name);
         } else redirect('account/login_admin');
    }
    public function show_item_3($he,$ra,$ty) //old //load item sau khi seach
    {
         if($this->session->userdata('role') == 1 || $this->session->userdata('role') == 3 ) {
    if($he == 'Allhero') $he1 = '';
            else $he1 = $he;
    if($ra == 'All') $ra1 = '';
            else $ra1 = $ra;
    if($ty == 'All') $ty1 = '';
            else $ty1 = $ty;
            
      //  var_dump($he); var_dump($ra);
        $this->load->library('pagination');
        $config['base_url']   = base_url(). "item/show_item_3/$he/$ra/$ty";
        $config['total_rows'] = $this->m_item->count_data($he1,$ra1,$ty1);
        $config['per_page']   = 15;
        $config['use_page_numbers']=TRUE;
        $config['uri_segment'] = 6;
         $config['full_tag_open'] = '<ul class="pagination">';
        $config['full_tag_close'] = '</ul>';
        $config['prev_link'] = '&lt;';
        $config['prev_tag_open'] = '<li>';
        $config['prev_tag_close'] = '</li>';
        $config['next_link'] = '&gt;';
        $config['next_tag_open'] = '<li>';
        $config['next_tag_close'] = '</li>';
        $config['cur_tag_open'] = '<li class="active"><a href="#">';
        $config['cur_tag_close'] = '</a></li>';
        $config['num_tag_open'] = '<li>';
        $config['num_tag_close'] = '</li>';
         
        $config['first_tag_open'] = '<li>';
        $config['first_tag_close'] = '</li>';
        $config['last_tag_open'] = '<li>';
        $config['last_tag_close'] = '</li>';
         
        $config['first_link'] = '&lt;&lt;';
        $config['last_link'] = '&gt;&gt;';
        $this->pagination->initialize($config); 
        $tranghienhanh = $this->uri->segment(6)?$this->uri->segment(6):1;
        $start = ($tranghienhanh-1)*$config['per_page'];
        $data['pagination'] = $this->pagination->create_links();
        $data['rarity'] = $this->m_item->get_all_rarity();
        $data['hero'] = $this->m_item->get_all_hero();
        $data['type'] = $this->m_item->get_all_type();
        
        $data['hero_search'] = $he ;
        $data['rarity_search'] = $ra;
        $data['type_search'] = $ty;
        
        $data['info'] = $this->m_item->lay_danh_sach_san_pham_phan_trang($he1,$ra1,$ty1,$config['per_page'],$start);
      //  $data['views'] = 'Item/Admin_ajax_list_item';
            $this->load->view("Item/Admin_item_list_2",$data);
     } else redirect('account/login_admin');
   //     $this->load->view('Item/Admin_item_list_2',$this->data);
    } 
    public function cap_nhat_gia()
    {
          if($this->session->userdata('role') == 1 || $this->session->userdata('role') == 3 ) {
        date_default_timezone_set('Asia/Ho_Chi_Minh');
        $url = $this->input->post('current');
        $date = getdate();
        $ngaycapnhat = $date['year'].'-'.$date['mon'].'-'.$date['mday'];
        $id = $this->input->post('item_id');
        $giamoi = $this->input->post('gia_moi');
        $kq = $this->m_item->update_price($id,$ngaycapnhat,$giamoi);
        redirect($url);
         } else redirect('account/login_admin');
    }
    function cap_nhat_sale_off_rieng()
    {
        if($this->session->userdata('role') == 1 || $this->session->userdata('role') == 3 ) {
        $url = $this->input->post('current');
        $from = $this->input->post('from');
        $to = $this->input->post('to');
        $id = $this->input->post('item_id');
        $saleoffrieng = $this->input->post('saleoffrieng');
        $update = $this->m_item->update_sale_rieng($id,$from,$to,$saleoffrieng);
        redirect($url);
         } else redirect('account/login_admin');
    }
    function cap_nhat_sale_off_chung()
    {
        if($this->session->userdata('role') == 1 || $this->session->userdata('role') == 3 ) {
        $url = $this->input->post('current');
        $from = $this->input->post('from');
        $to = $this->input->post('to');
        $saleoffchung = $this->input->post('saleoffchung');
        $update = $this->m_item->update_sale_chung($from,$to,$saleoffchung);
        redirect($url);
         } else redirect('account/login_admin');
    }
      public function show_item_phan_trang_theo_loai($type)
    {
        $this->load->library('pagination');
        $config['base_url']   = base_url(). "item/show_item_phan_trang_theo_loai/".$type;
        $config['total_rows'] = $this->m_item->count_data_by_type($type);
        $config['per_page']   = 16;
        $config['use_page_numbers']=TRUE;
        $config['uri_segment'] = 4;
         $config['full_tag_open'] = '<ul class="pagination">';
        $config['full_tag_close'] = '</ul>';
        $config['prev_link'] = '&lt;';
        $config['prev_tag_open'] = '<li>';
        $config['prev_tag_close'] = '</li>';
        $config['next_link'] = '&gt;';
        $config['next_tag_open'] = '<li>';
        $config['next_tag_close'] = '</li>';
        $config['cur_tag_open'] = '<li class="active"><a href="#">';
        $config['cur_tag_close'] = '</a></li>';
        $config['num_tag_open'] = '<li>';
        $config['num_tag_close'] = '</li>';
         
        $config['first_tag_open'] = '<li>';
        $config['first_tag_close'] = '</li>';
        $config['last_tag_open'] = '<li>';
        $config['last_tag_close'] = '</li>';
         
        $config['first_link'] = '&lt;&lt;';
        $config['last_link'] = '&gt;&gt;';
        $this->pagination->initialize($config); 
        $tranghienhanh = $this->uri->segment(4)?$this->uri->segment(4):1;
        $start = ($tranghienhanh-1)*$config['per_page'];
        $data['pagination'] = $this->pagination->create_links();
        $data['rarity'] = $this->m_item->get_all_rarity();
        $data['hero'] = $this->m_item->get_all_hero();  
        $data['List_Items'] = $this->m_item->lay_danh_sach_san_pham_phan_trang_theo_loai($type,$config['per_page'],$start);
        $this->load->view("Item/Show_Items",$data);    
    }
    public function show_item_phan_trang_theo_loai2($type)
    {
        $this->load->library('pagination');
        $config['base_url']   = base_url(). "item/show_item_phan_trang_theo_loai2/".$type;
        $config['total_rows'] = $this->m_item->count_data_by_type($type);
        $config['per_page']   = 16;
        $config['use_page_numbers']=TRUE;
        $config['uri_segment'] = 4;
         $config['full_tag_open'] = '<ul class="pagination">';
        $config['full_tag_close'] = '</ul>';
        $config['prev_link'] = '&lt;';
        $config['prev_tag_open'] = '<li>';
        $config['prev_tag_close'] = '</li>';
        $config['next_link'] = '&gt;';
        $config['next_tag_open'] = '<li>';
        $config['next_tag_close'] = '</li>';
        $config['cur_tag_open'] = '<li class="active"><a href="#">';
        $config['cur_tag_close'] = '</a></li>';
        $config['num_tag_open'] = '<li>';
        $config['num_tag_close'] = '</li>';
         
        $config['first_tag_open'] = '<li>';
        $config['first_tag_close'] = '</li>';
        $config['last_tag_open'] = '<li>';
        $config['last_tag_close'] = '</li>';
         
        $config['first_link'] = '&lt;&lt;';
        $config['last_link'] = '&gt;&gt;';
        $this->pagination->initialize($config); 
        $tranghienhanh = $this->uri->segment(4)?$this->uri->segment(4):1;
        $start = ($tranghienhanh-1)*$config['per_page'];
        $data['pagination'] = $this->pagination->create_links();
        $data['rarity'] = $this->m_item->get_all_rarity();
        $data['hero'] = $this->m_item->get_all_hero();  
        $data['typeset'] = $type;
        $data['List_Items'] = $this->m_item->lay_danh_sach_san_pham_phan_trang_theo_loai($type,$config['per_page'],$start);
        $this->load->view("Item/Show_Items_type",$data);    
    }
    public function searched_type()
    {
        $name = $this->input->post('item_name');
        if($name == '') {
        $he = $this->input->post('cboHero');
        $ra = $this->input->post('cboRarity');
        $ty = $this->input->post('typeset');
        if($he == 'All' || $he == '' ) $he = 'Allhero';
        if($ra == '' || $ra == 'All') $ra = 'All';
        if($ty == '' || $ty == 'All') $ty = 'All';
    //    echo $he; echo $ra; exit;
        $this->searched2_type($he,$ra,$ty); }
            else
            $this->searched_name($name);
    }
    
     public function searched2_type($he,$ra,$ty)
    {
        if($he == 'Allhero') $he1 = '';
            else $he1 = $he;
        if($ra == 'All') $ra1 = '';
            else $ra1 = $ra;
            if($ty == 'All') $ty1 = '';
            else $ty1 = $ty;
        $this->load->library('pagination');
        $config['base_url']   = base_url(). "item/searched2_type/$he/$ra/$ty";
       // echo base_url(). "item/searched2/$he/$ra"; exit;
        $config['total_rows'] = $this->m_item->count_data('',$ra1,$ty1);
        $config['per_page']   = 16;
        $config['use_page_numbers']=TRUE;
        $config['uri_segment'] = 6;
         $config['full_tag_open'] = '<ul class="pagination">';
        $config['full_tag_close'] = '</ul>';
        $config['prev_link'] = '&lt;';
        $config['prev_tag_open'] = '<li>';
        $config['prev_tag_close'] = '</li>';
        $config['next_link'] = '&gt;';
        $config['next_tag_open'] = '<li>';
        $config['next_tag_close'] = '</li>';
        $config['cur_tag_open'] = '<li class="active"><a href="#">';
        $config['cur_tag_close'] = '</a></li>';
        $config['num_tag_open'] = '<li>';
        $config['num_tag_close'] = '</li>';
         
        $config['first_tag_open'] = '<li>';
        $config['first_tag_close'] = '</li>';
        $config['last_tag_open'] = '<li>';
        $config['last_tag_close'] = '</li>';
         
        $config['first_link'] = '&lt;&lt;';
        $config['last_link'] = '&gt;&gt;';
        $this->pagination->initialize($config); 
        $tranghienhanh = $this->uri->segment(6)?$this->uri->segment(6):1;
        $start = ($tranghienhanh-1)*$config['per_page'];
        $data['pagination'] = $this->pagination->create_links();
        $data['rarity'] = $this->m_item->get_all_rarity();
        $data['hero'] = $this->m_item->get_all_hero();  
        $data['hero_search'] = $he ;
        $data['rarity_search'] = $ra;
        $data['List_Items'] = $this->m_item->lay_danh_sach_san_pham_phan_trang('',$ra1,$ty1,$config['per_page'],$start);
        $this->load->view("Item/Show_Items_type",$data);    
    }
    public function searched()
    {
        $name = $this->input->post('item_name');
        if($name == '') {
        $he = $this->input->post('cboHero');
        $ra = $this->input->post('cboRarity');
        if($he == 'All' || $he == '' ) $he = 'Allhero';
        if($ra == '' || $ra == 'All') $ra = 'All';
    //    echo $he; echo $ra; exit;
        $this->searched2($he,$ra); }
            else
            $this->searched_name($name);
    }
    
     public function searched2($he,$ra)
    {
        if($he == 'Allhero') $he1 = '';
            else $he1 = $he;
        if($ra == 'All') $ra1 = '';
            else $ra1 = $ra;
        $this->load->library('pagination');
        $config['base_url']   = base_url(). "item/searched2/$he/$ra";
       // echo base_url(). "item/searched2/$he/$ra"; exit;
        $config['total_rows'] = $this->m_item->count_data($he1,$ra1,'');
        $config['per_page']   = 16;
        $config['use_page_numbers']=TRUE;
        $config['uri_segment'] = 5;
         $config['full_tag_open'] = '<ul class="pagination">';
        $config['full_tag_close'] = '</ul>';
        $config['prev_link'] = '&lt;';
        $config['prev_tag_open'] = '<li>';
        $config['prev_tag_close'] = '</li>';
        $config['next_link'] = '&gt;';
        $config['next_tag_open'] = '<li>';
        $config['next_tag_close'] = '</li>';
        $config['cur_tag_open'] = '<li class="active"><a href="#">';
        $config['cur_tag_close'] = '</a></li>';
        $config['num_tag_open'] = '<li>';
        $config['num_tag_close'] = '</li>';
         
        $config['first_tag_open'] = '<li>';
        $config['first_tag_close'] = '</li>';
        $config['last_tag_open'] = '<li>';
        $config['last_tag_close'] = '</li>';
         
        $config['first_link'] = '&lt;&lt;';
        $config['last_link'] = '&gt;&gt;';
        $this->pagination->initialize($config); 
        $tranghienhanh = $this->uri->segment(5)?$this->uri->segment(5):1;
        $start = ($tranghienhanh-1)*$config['per_page'];
        $data['pagination'] = $this->pagination->create_links();
        $data['rarity'] = $this->m_item->get_all_rarity();
        $data['hero'] = $this->m_item->get_all_hero();  
        $data['hero_search'] = $he ;
        $data['rarity_search'] = $ra;
        $data['List_Items'] = $this->m_item->lay_danh_sach_san_pham_phan_trang($he1,$ra1,'',$config['per_page'],$start);
        $this->load->view("Item/Show_Items",$data);    
    }
     public function searched_name($name)
    {
        $this->load->library('pagination');
        $config['base_url']   = base_url(). "item/searched_name/$name";
       // echo base_url(). "item/searched2/$he/$ra"; exit;
        $config['total_rows'] = $this->m_item->get_item_by_name_count($name);
        $config['per_page']   = 16;
        $config['use_page_numbers']=TRUE;
        $config['uri_segment'] = 4;
         $config['full_tag_open'] = '<ul class="pagination">';
        $config['full_tag_close'] = '</ul>';
        $config['prev_link'] = '&lt;';
        $config['prev_tag_open'] = '<li>';
        $config['prev_tag_close'] = '</li>';
        $config['next_link'] = '&gt;';
        $config['next_tag_open'] = '<li>';
        $config['next_tag_close'] = '</li>';
        $config['cur_tag_open'] = '<li class="active"><a href="#">';
        $config['cur_tag_close'] = '</a></li>';
        $config['num_tag_open'] = '<li>';
        $config['num_tag_close'] = '</li>';
         
        $config['first_tag_open'] = '<li>';
        $config['first_tag_close'] = '</li>';
        $config['last_tag_open'] = '<li>';
        $config['last_tag_close'] = '</li>';
         
        $config['first_link'] = '&lt;&lt;';
        $config['last_link'] = '&gt;&gt;';
        $this->pagination->initialize($config); 
        $tranghienhanh = $this->uri->segment(4)?$this->uri->segment(4):1;
        $start = ($tranghienhanh-1)*$config['per_page'];
        $data['pagination'] = $this->pagination->create_links();
        $data['rarity'] = $this->m_item->get_all_rarity();
        $data['hero'] = $this->m_item->get_all_hero();  
      //  $data['hero_search'] = $he ;
      //  $data['rarity_search'] = $ra;
        $data['List_Items'] = $this->m_item->get_item_by_name($name,$config['per_page'],$start);
        $this->load->view("Item/Show_Items",$data);    
    }
    function show_bundle_by_hero($hero)
    {
        $this->load->library('pagination');
        $config['base_url']   = base_url(). "item/show_bundle_by_hero/".$hero;
        $config['total_rows'] = $this->m_item->count_data_by_hero($hero);
        $config['per_page']   = 16;
        $config['use_page_numbers']=TRUE;
        $config['uri_segment'] = 4;
         $config['full_tag_open'] = '<ul class="pagination">';
        $config['full_tag_close'] = '</ul>';
        $config['prev_link'] = '&lt;';
        $config['prev_tag_open'] = '<li>';
        $config['prev_tag_close'] = '</li>';
        $config['next_link'] = '&gt;';
        $config['next_tag_open'] = '<li>';
        $config['next_tag_close'] = '</li>';
        $config['cur_tag_open'] = '<li class="active"><a href="#">';
        $config['cur_tag_close'] = '</a></li>';
        $config['num_tag_open'] = '<li>';
        $config['num_tag_close'] = '</li>';
         
        $config['first_tag_open'] = '<li>';
        $config['first_tag_close'] = '</li>';
        $config['last_tag_open'] = '<li>';
        $config['last_tag_close'] = '</li>';
         
        $config['first_link'] = '&lt;&lt;';
        $config['last_link'] = '&gt;&gt;';
        $this->pagination->initialize($config); 
        $tranghienhanh = $this->uri->segment(4)?$this->uri->segment(4):1;
        $start = ($tranghienhanh-1)*$config['per_page'];
        $data['pagination'] = $this->pagination->create_links();
        $data['rarity'] = $this->m_item->get_all_rarity();
        $data['hero'] = $this->m_item->get_all_hero();  
        $data['hero_found'] = $hero;
        $data['List_Items'] = $this->m_item->lay_danh_sach_san_pham_phan_trang_theo_hero($hero,$config['per_page'],$start);
        $this->load->view("Item/Show_Items_bundle_hero",$data);    
    
    }
      public function searched_hero()
    {
        $name = $this->input->post('item_name');
        if($name == '') {
        $he = $this->input->post('cboHero');
        $ra = $this->input->post('cboRarity');
      //  $ty = $this->input->post('typeset');
        if($he == 'All' || $he == '' ) $he = 'Allhero';
        if($ra == '' || $ra == 'All') $ra = 'All';
    //    if($ty == '' || $ty == 'All') $ty = 'All';
    //    echo $he; echo $ra; exit;
        $this->searched2_hero($he,$ra); }
            else
            $this->searched_name($name);
    }
    
     public function searched2_hero($he,$ra)
    {
        if($he == 'Allhero') $he1 = '';
            else $he1 = $he;
        if($ra == 'All') $ra1 = '';
            else $ra1 = $ra;

        $this->load->library('pagination');
        $config['base_url']   = base_url(). "item/searched2_hero/$he/$ra";
       // echo base_url(). "item/searched2/$he/$ra"; exit;
        $config['total_rows'] = $this->m_item->count_data($he1,$ra1,'bunddle');
        $config['per_page']   = 16;
        $config['use_page_numbers']=TRUE;
        $config['uri_segment'] = 5;
         $config['full_tag_open'] = '<ul class="pagination">';
        $config['full_tag_close'] = '</ul>';
        $config['prev_link'] = '&lt;';
        $config['prev_tag_open'] = '<li>';
        $config['prev_tag_close'] = '</li>';
        $config['next_link'] = '&gt;';
        $config['next_tag_open'] = '<li>';
        $config['next_tag_close'] = '</li>';
        $config['cur_tag_open'] = '<li class="active"><a href="#">';
        $config['cur_tag_close'] = '</a></li>';
        $config['num_tag_open'] = '<li>';
        $config['num_tag_close'] = '</li>';
         
        $config['first_tag_open'] = '<li>';
        $config['first_tag_close'] = '</li>';
        $config['last_tag_open'] = '<li>';
        $config['last_tag_close'] = '</li>';
         
        $config['first_link'] = '&lt;&lt;';
        $config['last_link'] = '&gt;&gt;';
        $this->pagination->initialize($config); 
        $tranghienhanh = $this->uri->segment(5)?$this->uri->segment(5):1;
        $start = ($tranghienhanh-1)*$config['per_page'];
        $data['pagination'] = $this->pagination->create_links();
        $data['rarity'] = $this->m_item->get_all_rarity();
        $data['hero'] = $this->m_item->get_all_hero();  
        $data['hero_search'] = $he ;
        $data['rarity_search'] = $ra;
        $data['List_Items'] = $this->m_item->lay_danh_sach_san_pham_phan_trang($he1,$ra1,'bundle',$config['per_page'],$start);
        $this->load->view("Item/Show_Items_bundle_hero",$data);    
    }
    
}

?>